package com.bao.camelcase.test;

import com.bao.camelcase.CamelCase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class CamelCaseTester {

    public static String[] testData;
    public static String expectedResult;

    @Before
    public void setUp() {
        testData = new String[]{"Get", "first", "REFERENCE"};
        expectedResult = "getFirstReference";

    }

    @Test
    public void checkCamelCase() {
        String result = CamelCase.convertToCamelCase(testData);
        Assert.assertEquals(result, expectedResult);
    }

    @Test(expected = NullPointerException.class)
    public void throwException_whenAllArrayIsNull() {
        testData = null;
        String result = CamelCase.convertToCamelCase(testData);
        Assert.assertEquals(result, expectedResult);
    }

    @Test(expected = NullPointerException.class)
    public void throwException_whenOneElementOfArrayIsNull() {
        testData[2] = null;
        String result = CamelCase.convertToCamelCase(testData);
        Assert.assertEquals(result, expectedResult);
    }

    @Test
    public void shouldConverting_whenOneElementOfArrayIsEmpty() {
        testData[0] = "";
        expectedResult = "FirstReference";
        String result = CamelCase.convertToCamelCase(testData);
        Assert.assertEquals(result, expectedResult);
    }

    @Test
    public void shouldIgnore_whenArrayHasSpaceElements() {
        testData[1] = " ";
        expectedResult = "getReference";
        String result = CamelCase.convertToCamelCase(testData);
        Assert.assertEquals(result, expectedResult);
    }
}
